home *** CD-ROM | disk | FTP | other *** search
- Program Page2Cfg;
-
- (*---------------------------------------------------------------------------*)
- (* *)
- (* PAGE2CFG Version 1.0 *)
- (* *)
- (* Default Option Customization for the Page2 program *)
- (* *)
- (* by: R. P. Byrne June 4, 1988 *)
- (* *)
- (*---------------------------------------------------------------------------*)
- (* *)
- (* I have placed this program and it's source code into the public *)
- (* domain in the hope that it may prove useful to someone other than *)
- (* myself. *)
- (* *)
- (* Please feel free to distribute this program by any means available. I *)
- (* only ask, as a courtesy, that the program not be distributed without *)
- (* the inclusion of the source code and the accompanying documentation *)
- (* file. *)
- (* *)
- (* Since this program is truly public domain software, if you paid *)
- (* someone more than $5.00 to receive it, you've probably been ripped *)
- (* off. *)
- (* *)
- (* rpb *)
- (* 6/4/88 *)
- (* *)
- (*---------------------------------------------------------------------------*)
-
- Uses Crt,
- Dos,
- StrProcs;
-
- Type
- DefaultsRec = Record
- StartPatch : String[16]; {17}
- CPL : Word; { 2}
- LPP : Word; { 2}
- BindMar : Word; { 2}
- UseFF : Boolean; { 1}
- OddFirst : Boolean; { 1}
- PrintName : Boolean; { 1}
- PrintDate : Boolean; { 1}
- PrintPgNo : Boolean; { 1}
- EndPatch : String[14]; {15}
- end {record};
-
- Const
- DefaultsLoc = $4630; { Offset of patch area in Page2.Exe }
- InFileName : String = 'Page2.Exe';
-
- Var
- Defaults : DefaultsRec;
-
- InFile : File;
-
- { --------------------------------------------------------------------------- }
-
- Procedure Abort(ErrMsg : String);
- Begin
- If ErrMsg <> '' then begin
- Writeln;
- Writeln(ErrMsg);
- Writeln;
- Writeln('Program aborted.');
- Writeln;
- end {if};
- Halt(255);
- End {Abort};
-
- { --------------------------------------------------------------------------- }
-
- Procedure GetDefaults;
- Var
- BytesRead : Word;
- Begin
- Assign(InFile, InFileName);
- Reset(InFile, 1);
- Seek(InFile, DefaultsLoc);
- BlockRead(InFile, Defaults, SizeOf(Defaults), BytesRead);
- If BytesRead <> SizeOf(Defaults) then
- Abort('Unexpected end of file encountered in ' + InFileName);
- If (Defaults.StartPatch <> 'Patch Area Start') or
- (Defaults.EndPatch <> 'Patch Area End') then
- Abort('Synch error in file ' + InFileName);
- Close(InFile);
- end {GetDefaults};
-
- { --------------------------------------------------------------------------- }
-
- Procedure SetDefaults;
- Const
- ReadWriteMode = 2;
- Begin
- Assign(InFile, InFileName);
- FileMode := ReadWriteMode;
- Reset(InFile, 1);
- Seek(InFile, DefaultsLoc);
- BlockWrite(InFile, Defaults, SizeOf(Defaults));
- Close(InFile);
- end {SetDefaults};
-
- { --------------------------------------------------------------------------- }
-
- Procedure GetNewDefaults;
- Var
- Answer : String;
- TestNum : Integer;
- Code : Integer;
- Begin
- With Defaults do begin
- Repeat
- Answer := '';
- Write('Enter default page width in characters [', CPL, ']: ');
- Readln(Answer);
- Code := 0;
- If Answer = '' then
- TestNum := CPL
- else
- Val(Answer, TestNum, Code);
- Until (Code = 0) or (TestNum > 0);
- CPL := TestNum;
-
- Repeat
- Answer := '';
- Write('Enter default page length in lines [', LPP, ']: ');
- Readln(Answer);
- Code := 0;
- If Answer = '' then
- TestNum := LPP
- else
- Val(Answer, TestNum, Code);
- Until (Code = 0) or (TestNum > 0);
- LPP := TestNum;
-
- Repeat
- Answer := '';
- Write('Enter default gutter margin size in characters [', BindMar, ']: ');
- Readln(Answer);
- Code := 0;
- If Answer = '' then
- TestNum := BindMar
- else
- Val(Answer, TestNum, Code);
- Until (Code = 0) and (TestNum >= 0);
- BindMar := TestNum;
-
- Repeat
- Answer := '';
- Write('Follow every page with a formfeed? [');
- If UseFF then
- Write('Y]: ')
- else
- Write('N]: ');
- Readln(Answer);
- If Answer = '' then
- If UseFF then
- Answer := 'Y'
- else
- Answer := 'N';
- Answer := Strip(Answer);
- Until (Upcase(Answer[1]) in ['Y', 'N']);
- UseFF := (UpCase(Answer[1]) = 'Y');
-
- Repeat
- Answer := '';
- Write('Print the odd pages first? [');
- If OddFirst then
- Write('Y]: ')
- else
- Write('N]: ');
- Readln(Answer);
- If Answer = '' then
- If OddFirst then
- Answer := 'Y'
- else
- Answer := 'N';
- Answer := Strip(Answer);
- Until (Upcase(Answer[1]) in ['Y', 'N']);
- OddFirst := (UpCase(Answer[1]) = 'Y');
-
- Repeat
- Answer := '';
- Write('Include the file name in a running header? [');
- If PrintName then
- Write('Y]: ')
- else
- Write('N]: ');
- Readln(Answer);
- If Answer = '' then
- If PrintName then
- Answer := 'Y'
- else
- Answer := 'N';
- Answer := Strip(Answer);
- Until (Upcase(Answer[1]) in ['Y', 'N']);
- PrintName := (UpCase(Answer[1]) = 'Y');
-
- Repeat
- Answer := '';
- Write('Include the current date in a running header? [');
- If PrintDate then
- Write('Y]: ')
- else
- Write('N]: ');
- Readln(Answer);
- If Answer = '' then
- If PrintDate then
- Answer := 'Y'
- else
- Answer := 'N';
- Answer := Strip(Answer);
- Until (Upcase(Answer[1]) in ['Y', 'N']);
- PrintDate := (UpCase(Answer[1]) = 'Y');
-
- Repeat
- Answer := '';
- Write('Include the page number in a running header? [');
- If PrintPgNo then
- Write('Y]: ')
- else
- Write('N]: ');
- Readln(Answer);
- If Answer = '' then
- If PrintPgNo then
- Answer := 'Y'
- else
- Answer := 'N';
- Answer := Strip(Answer);
- Until (Upcase(Answer[1]) in ['Y', 'N']);
- PrintPgNo := (UpCase(Answer[1]) = 'Y');
-
- end {with};
- end {GetNewDefaults};
-
- { --------------------------------------------------------------------------- }
-
- Var
- Next : Char;
- Begin
- Repeat
- TextColor(Yellow);
- TextBackground(Black);
- ClrScr;
- Writeln;
- Writeln('Page2 - Generic 2-sided print utility - by R. P. Byrne 5/24/88');
- Writeln;
- Writeln('Customization program for default program option settings');
- Writeln;
- TextColor(LightGreen);
- GetDefaults;
- GetNewDefaults;
- TextColor(Yellow);
- Writeln;
- Writeln('What next?');
- Write('(S)ave new settings, (Q)uit without save, (R)especify settings? ');
- Repeat
- Next := ReadKey;
- Until (Upcase(Next) in ['S', 'Q', 'R']);
- Writeln(UpCase(Next));
- If UpCase(Next) = 'S' then
- SetDefaults;
- Until (Upcase(Next) <> 'R');
- End.
-